﻿using CREAPA.Dominio;
using CREAPA.Repositorio;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CREAPA.RepositorioADO
{
    public class ReportADO
    {
        
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["StringConexaosqlserver"].ConnectionString);

        public DataTable GetContracheque(string cpf, int ano, int mes, int tipoFolha)
        {
            DataTable dt = new DataTable();
            try
            {
                con.Open();

                //SqlCommand cmd = new SqlCommand("SELECT * FROM Cargo where id in (1,3)", con);
                SqlCommand cmd = new SqlCommand("Stprc_ConsContra_Cheque_completo", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@cpffunc", cpf));
                cmd.Parameters.Add(new SqlParameter("@ano", ano));
                cmd.Parameters.Add(new SqlParameter("@mes", mes));
                cmd.Parameters.Add(new SqlParameter("@TipoFolha", tipoFolha));

                SqlDataAdapter adp = new SqlDataAdapter(cmd);

                adp.Fill(dt);
            }

            catch (Exception ex)
            {

            }
            return dt;
        }

        public DataTable GetPortaria(int id)
        {
            DataTable dt = new DataTable();
            try
            {
                con.Open();

                SqlCommand cmd = new SqlCommand("Stprc_ConsPortaria", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@id", id));

                SqlDataAdapter adp = new SqlDataAdapter(cmd);

                adp.Fill(dt);
            }

            catch (Exception ex)
            {

            }
            return dt;
        }

        public DataTable GetLogin(string login)
        {
            DataTable dt = new DataTable();
            try
            {
                con.Open();

                //SqlCommand cmd = new SqlCommand("SELECT * FROM Cargo where id in (1,3)", con);
                SqlCommand cmd = new SqlCommand("Stprc_cons_login", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@login", login));

                SqlDataAdapter adp = new SqlDataAdapter(cmd);

                adp.Fill(dt);
            }

            catch (Exception ex)
            {

            }
            return dt;
        }
    }
}
